﻿using System;
using System.Diagnostics;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media;
using Microsoft.Surface.Presentation.Controls;

namespace MTBrainStorm.Views
{
    /// <summary>
    /// Interaction logic for Element.xaml
    /// </summary>
    public partial class Element : UserControl
    {
        public ICommand DropCommand
        {
            get { return (ICommand) GetValue(DropCommandProperty); }
            set { SetValue(DropCommandProperty, value); }
        }

        public static readonly DependencyProperty DropCommandProperty = DependencyProperty.Register("DropCommand",
                                                                                          typeof (ICommand),
                                                                                          typeof (Element),
                                                                                          new FrameworkPropertyMetadata(
                                                                                              new PropertyChangedCallback
                                                                                                  (UpdateDropCommand)));
        
        private static void UpdateDropCommand(DependencyObject source, DependencyPropertyChangedEventArgs e)
        {
            ((Element) source).Drop += (sender, args) => ((ICommand) e.NewValue).Execute(null);
        }

        public Element()
        {
            InitializeComponent();
        }
    }
}
